package com.example.flipviewdemo1;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.BaseAdapter;

import com.aphidmobile.flip.FlipViewController;

public class MainActivity extends Activity {
	protected FlipViewController flipView;

	@SuppressLint("SetJavaScriptEnabled")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setTitle("abc");
		int mCount = 10;

		String mHeader = "<h1>Hello, WebView </h1></br>";
		for (int i = 0; i < 100; i++) {
			mHeader += "<h1>Hello, WebView " + String.valueOf(i) + "</h1></br>";
		}
		final String customHtml = "<html><body>" + mHeader + "</body></html>";
		final WebView mWebView = new WebView(getApplicationContext());
		mWebView.loadData(customHtml, "text/html", "UTF-8");
		flipView = new FlipViewController(this);

		flipView.setAdapter(new BaseAdapter() {
			@Override
			public int getCount() {
				return 10;
			}

			@Override
			public Object getItem(int position) {
				return position;
			}

			@Override
			public long getItemId(int position) {
				return position;
			}

			@SuppressLint("SetJavaScriptEnabled")
			@Override
			public View getView(int position, View convertView, ViewGroup parent) {
				if (convertView == null) {
					mWebView.loadData(customHtml, "text/html", "UTF-8");
					mWebView.scrollTo(0, position * 500);
				} else {
					mWebView.scrollTo(0, position * 500);
				}

				WebViewClient mm = new WebViewClient();

				return mWebView;
			}
		});

		setContentView(flipView);

	}
}
